You have been hearing complaints from people saying they are unable to write emails to Mr. Müller. You quickly realize that most of the company uses an old email client that doesn't recognize müller@firma.de as a valid email address because of the non-Latin character.
Telling people to give up their favorite old email client is a lost battle, so you decide to create sanitized aliases for all email accounts.
Implement the sanitize/1 function. It should accept a username as a charlist and return the username with all characters but lowercase letters removed.
Extend the sanitize/1 function. It should not remove underscores from the username.
There are 4 non-Latin characters in the German alphabet, and all of them have commonly-recognized Latin substitutes.
Extend the sanitize/1 function. It should substitute German characters according to the table. You can safely assume all usernames are already downcase.
https://exercism.org/tracks/elixir/exercises/german-sysadmin
defmodule Username do
@moduledoc """
practice case and charlist
"""
@doc """
a - z === 97 - 122
"""
@spec sanitize(charlist) :: charlist
def sanitize(''), do: ''
def sanitize([head | tail]) do
first_letter = case head do
?ä -> 'ae'
?ö -> 'oe'
?ü -> 'ue'
?ß -> 'ss'
?_ -> '_'
head when head in ?a..?z -> [head]
_ -> ''
end
first_letter ++ sanitize(tail)
end
end